package ${sys.getPKGCodeName()}.${item.getParentPSModelObject(net.ibizsys.model.dataentity.IPSDataEntity.class).getPSSystemModule().realCodeName.toLowerCase()}.${item.getParentPSModelObject(net.ibizsys.model.dataentity.IPSDataEntity.class).realCodeName.toLowerCase()}.logic

import net.ibizsys.central.cloud.core.dataentity.logic.DELogicRuntime
import net.ibizsys.central.dataentity.logic.IDELogicSession
import net.ibizsys.model.dataentity.logic.IPSDELogicNode

import org.apache.commons.logging.Log
import org.apache.commons.logging.LogFactory

/**
 * 实体[${item.getParentPSModelObject(net.ibizsys.model.dataentity.IPSDataEntity.class).name}]处理逻辑[${item.logicName}]运行时对象
 * 此代码用户功能扩展代码
 *
 * ${item.memo}
 */
class ${item.realCodeName.capitalize()} extends DELogicRuntime {

    private static final Log log = LogFactory.getLog(${item.realCodeName.capitalize()}.class)

    @Override
	protected void onInit() throws Exception {
		super.onInit()
	}

    @Override
    protected void onExecutePSDELogicNode(IDELogicSession iDELogicSession, IPSDELogicNode iPSDELogicNode) throws Throwable {
        switch (iPSDELogicNode.getCodeName()) {
<% item.getPSDELogicNodes().each { node -> %>\
            case "${node.codeName}":
                //执行逻辑节点[${node.name}]
                execute${node.realCodeName.capitalize()}(iDELogicSession, iPSDELogicNode)
                break
<%}%>\
            default:
                super.onExecutePSDELogicNode(iDELogicSession, iPSDELogicNode)
        }
    }
<% item.getPSDELogicNodes().each { node -> %>\

    /**
     * 执行逻辑节点[${node.name}]，逻辑类型[${node.getLogicNodeType()}]
     * @param iDELogicSession
     * @param iPSDELogicNode
     * @throws Throwable
     */
    private void execute${node.realCodeName.capitalize()}(IDELogicSession iDELogicSession, IPSDELogicNode iPSDELogicNode) throws Throwable {
<% if('RAWSFCODE' == node.getLogicNodeType() && 'Groovy' == node.getCodeType()) { %>\
        // 执行Groovy脚本代码
        def objRet = { sys,logic ->
            ${node.code.replaceAll("\n", "\n\t\t\t")}
        }.call(iDELogicSession.getDELogicRuntime().getSystemRuntime(), iDELogicSession.getDELogicRuntime())
        //设置返回值
        iDELogicSession.setLastReturn(objRet);
        if(iPSDELogicNode.getRetPSDELogicParam() != null) {
            def retDELogicParamRuntime = this.getDELogicParamRuntime(iPSDELogicNode.getRetPSDELogicParam().getCodeName(), false);
            retDELogicParamRuntime.bind(iDELogicSession, objRet);
        }
        //super.onExecutePSDELogicNode(iDELogicSession, iPSDELogicNode, true)
<%} else {%>\
        super.onExecutePSDELogicNode(iDELogicSession, iPSDELogicNode, true)
<%}%>\
    }
<%}%>\
}

